# utf-8
# 计算一个数字N次开平方与N次乘2值的比较
# 20200217


def count(num, n):
    res_squire = num
    res_double = num
    i = 0
    while i < n:
        res_double *= 2
        res_squire *= res_squire
        i += 1
    return res_squire, res_double

if __name__ == '__main__':
    n = 104  # 计算的次数
    num = 0.031 # 初始值, 注意如果是小数开平方的结果会趋近于零
    a,b=count(num, n)
    print("%0.3f平方%d次的结果: %e"%(num,n,a))
    print("%0.3f翻倍%d次的结果: %e"%(num,n,b))
    print("翻倍的长度相当于%e光年"%(b/1000/1000/3E5/3600/24/365))
    print("翻倍的长度相当于%e光年"%(b/1000/1000/9.46E12))
